import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
export default new Router({
  //去掉url上的#
  mode: 'history',
  routes: [
    {
      path: '/sbadmin',
      name: 'sbadmin',
      component: resolve => require(['../components/page/sbadmin.vue'], resolve)
    },
    {
      path: '/',
      name: 'index',
      component: resolve => require(['../components/index.vue'], resolve),
      redirect: '/sbadmin',
      children: [{
        path: '/sbadmin',
        name: 'sbadmin',
        component: resolve => require(['../components/page/sbadmin.vue'], resolve)

      }]

    },
    {
      path: '/buttons',
      name: 'buttons',
      component: resolve => require(['../components/page/buttons.vue'], resolve)
    },
    {
      path: '/cards',
      name: 'cards',
      component: resolve => require(['../components/page/cards.vue'], resolve)
    },
    {
      path: '/color',
      name: 'color',
      component: resolve => require(['../components/page/color.vue'], resolve)
    },
    {
      path: '/border',
      name: 'border',
      component: resolve => require(['../components/page/border.vue'], resolve)
    },
    {
      path: '/login',
      name: 'login',
      component: resolve => require(['../views/login.vue'], resolve)
    },
    {
      path: '/*',
      name: '404',
      component: resolve => require(['../components/err.vue'], resolve)
    },
  ]
})
